package com.qisu.command;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Component;

import com.qisu.converters.Converters;

import io.netty.channel.ChannelHandlerContext;

/**
 * Acknowledgment of stop charge from station
 *
 * @author alsan
 *
 */
@Component
public class CMD6 extends AbstractSinexcelCmd {
//	@Autowired private OrderService _svc;

	@PostConstruct
	@Override
	protected void init() {
		super.init();

		fieldsList.addField(new CommandFieldDef<Integer>(2))
				.addField(new CommandFieldDef<Integer>(2))
				.addField(new CommandFieldDef<String>(32, Converters.strConverter, "充电桩ID"))
				.addField(new CommandFieldDef<Byte>(1, Converters.byteConverter, "充电枪口"))
				.addField(new CommandFieldDef<Integer>(4, Converters.intConverter, "命令启始标志"))
				.addField(new CommandFieldDef<Byte>(1, Converters.byteConverter, "命令个数"))
				.addField(new CommandFieldDef<Byte>(1, Converters.byteConverter, "执行结果"));
	}

	@Override
	protected void processCmd(ChannelHandlerContext ctx, byte[] req)  {/*
		byte result = _fieldsList.getValue("执行结果");
		String pileSerial = _fieldsList.getValue("充电桩ID");
		int gunNo = ((Byte)_fieldsList.getValue("充电枪口")).intValue();
		
		HashMap<String, Object> packetData = new HashMap<String, Object>() {
			private static final long serialVersionUID = 2829023691725723114L;

			{
				put("充电桩ID", _fieldsList.getValue("充电桩ID"));
				put("充电枪口", _fieldsList.getValue("充电枪口"));
				put("命令启始标志", _fieldsList.getValue("命令启始标志"));
				put("命令个数", _fieldsList.getValue("命令个数"));
				put("执行结果", _fieldsList.getValue("执行结果"));
			}
		};

		if(0 == result) {
			_svc.stopCharge(pileSerial,gunNo);
			//_svc.updateRefund(id);  //对账单  
			//_svc.settleAccount(id); //钱包账户
			//_svc.settleOrder(id);  //充电状态03-->04
		} else {
			_svc.setTimeoutError(pileSerial);
		}
	*/}

	@Override
	protected void responseClient(ChannelHandlerContext ctx) {
		// nothing to do here
	}

}
